//
//  ViewController.m
//  jisuanqi
//
//  Created by mac on 16-3-1.
//  Copyright (c) 2016年 hyd. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)method{

    NSString * text1 = self.textField1.text;
    NSString * text2 = self.textField2.text;
    int num1 = [text1 intValue];
    int num2 = [text2 intValue];
    int result = 0;
    // result = num1 - num2;
    
    NSString * yusuanfu = self.pl.text;
    char ysf = [yusuanfu characterAtIndex:0];
    switch (ysf) {
        case '+':
            result = num1+num2;
            break;
        case '-':
            result = num1-num2;
            break;
        case '*':
            result = num1*num2;
            break;
        case '/':
            result = num1/num2;
            break;
        default:
            break;
    }
    
    
    NSString * output = [NSString stringWithFormat:@"%d",result];
    
    self.res.text = output;
    NSLog(@"%d",result);
    [self.view endEditing:YES];
    
    //NSLog(@"计算按钮被点击了");

}


- (IBAction)puls{
    self.pl.text = @"+";

}

- (IBAction)jian{

self.pl.text = @"-";
}
- (IBAction)cheng{
    self.pl.text = @"*";


}
- (IBAction)chu{
    self.pl.text = @"/";

}

@end
